package com.study.servlet;

import com.study.R;
import com.study.dao.AwardInfoDAO;
import com.study.dao.impl.AwardInfoDAOImpl;
import com.study.dto.MedalDto;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @PackgeName: com.study.servlet
 * @ClassName: SportingServlet
 * @Author: 严志祥
 * Date: 2022-05-14 19:47
 * project name: web_project_medal
 * @Version:
 * @Description:
 */
@WebServlet("/sporting.let")
public class SportingServlet extends HttpServlet {
    private AwardInfoDAO dao = new AwardInfoDAOImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try{
            String name = req.getParameter("sportingName");
            System.out.println(name);
            List<MedalDto> list = dao.selectSporting(name);
            req.setAttribute("list",list);


            list.forEach(item->{
                System.out.println(item.getAthletesName());
            });
            req.getRequestDispatcher("/sporting.jsp").forward(req,resp);
        }catch (Exception e){
           e.printStackTrace();
        }
    }
}
